package t20211224;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * @Author: DengJia
 * @Date: 2021/12/24 21:22
 * @Description:
 */
public class Main {
    public static void main(String[] args) {
        List<Apple> aL = new ArrayList<Apple>() {{
            add(new Apple());
            add(new Apple());
            add(new Apple());
        }};

        for (Apple a : aL) System.out.println(a.id());


        List<Integer> is1 = new ArrayList<Integer>() {{
            add(3);
            add(1);
            add(2);
        }};

        List<Integer> is2 = Arrays.asList(33, 11, 22);
        System.out.println(is2);
        Collections.addAll(is1, 6, 6, 6);
        // 异常：UnsupportedOperationException（不支持的操作异常）因为is1其本质还是数组，不具备集合的特性。
        // Collections.addAll(is2, 6, 6, 6);
        System.out.println(is1);
        System.out.println(is1.subList(0, 3));
        Collections.shuffle(is1);
        System.out.println(is1);
        System.out.println(is1.subList(0, 3));
        is1.retainAll(is1.subList(0, 3));
        System.out.println(is1);
        is1.set(0, 9999);
        System.out.println(is1);

    }
}
